package com.jlect.swebing.ui.client;

/**
 * Redirects mouse events to the target component
 *
 * @author Sergey Kozmin
 * @since 01.12.2007 15:50:56
 */
public class MouseEventsRedirector implements MouseListener {
    private GComponent target;

    public MouseEventsRedirector(GComponent target) {
        if(target == null) {
            throw new IllegalArgumentException("Target component could not be null. ");
        }
        this.target = target;
    }

    private void fireMouseEvent(MouseEvent e) {
        e.setSource(target);
        target.getMouseListeners().fireEvent(e.getMouseType(), e);
    }

    public void mouseClicked(MouseEvent e) {
        fireMouseEvent(e);
    }

    public void mousePressed(MouseEvent e) {
       fireMouseEvent(e);
    }

    public void mouseReleased(MouseEvent e) {
        fireMouseEvent(e);
    }

    public void mouseEntered(MouseEvent e) {
        fireMouseEvent(e);
    }

    public void mouseExited(MouseEvent e) {
        fireMouseEvent(e);
    }
}
